import request from '@/utils/request';

/**
 * 配置
 */
export async function config(data) {
  const res = await request.post('/config/index', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改配置
export async function configEdit(data) {
  const res = await request.post('/config/edit', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 模版通知
export async function messageList(data) {
  const res = await request.post('/message/index', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function delNoticeMessage(data) {
  const res = await request.post('/message/delNoticeMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function editNoticeMessage(data) {
  const res = await request.post('/message/editNoticeMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 修改版本通知id
export async function messageEdit(data) {
  const res = await request.post('/message/editMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改模版状态

export async function messageStatus(data) {
  const res = await request.post('/message/status', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 获取定时任务
export async function timing(data) {
  const res = await request.post('/config/Timing', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 消息通知
export async function noticeMessage(data) {
  const res = await request.post('/message/noticeMessage', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function sendNoticeMessage(data) {
  const res = await request.post('/message/sendNoticeMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
